<?php
class Custom_Application_Resource_View
    extends Zend_Application_Resource_ResourceAbstract
{
    protected $_view;

    public function init()
    {
        if (null === $this->_view) {
            $options = $this->getOptions();
            $this->_view = new Zend_View($options);

            if (isset($options['encoding'])) {
                $this->_view->setEncoding($options['encoding']);
            }

            if (isset($options['doctype'])) {
                $this->_view->doctype(strtoupper($options['doctype']));
            }

           if (isset($options['params'])) {
                foreach ($options['params'] as $key => $value) {
                    $this->_view->$key = $value;
                }
            }
            
            $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
            $viewRenderer->setView($this->_view);
            
            Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
        }
        return $this->_view;
    }
}
?>